<?php

namespace app\admin\validate\admin;

use ShidianUtil\Thinkphp\Validate\BaseValidate;

/**
 * Class Admin
 * @package app\admin\validate
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037623
 */
class Admin extends BaseValidate
{

    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'	=> 'isId',
		'username'	=> 'scalar|max:32',
		'password'	=> 'scalar|max:32',
		'salt'	=> 'scalar|max:6',
		'isAdmin'	=> 'integer|egt:0|max:3',
		'name'	=> 'scalar|max:12',
		'mobile'	=> 'scalar|max:16',
		'email'	=> 'scalar|max:32',
		'roleId'	=> 'integer|egt:0|max:10',
		'status'	=> 'integer|egt:0|max:3',
		'secretKey'	=> 'scalar|max:32',
		'created'	=> 'integer|egt:0|max:11',
		'updated'	=> 'integer|egt:0|max:11',
		'systemId'	=> 'integer|egt:0|max:1',
		'departmentId'	=> 'integer|egt:0|max:11',
        'page'      => 'integer|egt:0|max:11',
        'page_size' => 'integer|egt:0|max:11',
    ];

    protected $field = [
        'id'	=> 'id',
		'username'	=> 'username',
		'password'	=> 'password',
		'salt'	=> 'salt',
		'isAdmin'	=> 'isAdmin',
		'name'	=> 'name',
		'mobile'	=> 'mobile',
		'email'	=> 'email',
		'roleId'	=> 'roleId',
		'status'	=> 'status',
		'secretKey'	=> 'secretKey',
		'created'	=> 'created',
		'updated'	=> 'updated',
		'systemId'	=> 'systemId',
		'departmentId'	=> 'departmentId',
        'page'      => '分页页数',
        'page_size' => '分页大小',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require'	=> '缺少:attribute',
		'id.isId'	=> '请设置正确的:attribute',
		'username.require'	=> '请输入:attribute',
		'username.scalar' => ':attribute应该是字符串',
		'username.max'	=> ':attribute长度不能超过:rule位',
		'password.require'	=> '请输入:attribute',
		'password.scalar' => ':attribute应该是字符串',
		'password.max'	=> ':attribute长度不能超过:rule位',
		'salt.require'	=> '请输入:attribute',
		'salt.scalar' => ':attribute应该是字符串',
		'salt.max'	=> ':attribute长度不能超过:rule位',
		'isAdmin.require'	=> '请输入:attribute',
		'isAdmin.integer' => ':attribute应该是整数',
		'isAdmin.egt'	=> ':attribute应该大于等于:rule',
		'isAdmin.max'	=> ':attribute长度不能超过:rule位',
		'name.require'	=> '请输入:attribute',
		'name.scalar' => ':attribute应该是字符串',
		'name.max'	=> ':attribute长度不能超过:rule位',
		'mobile.require'	=> '请输入:attribute',
		'mobile.scalar' => ':attribute应该是字符串',
		'mobile.max'	=> ':attribute长度不能超过:rule位',
		'email.require'	=> '请输入:attribute',
		'email.scalar' => ':attribute应该是字符串',
		'email.max'	=> ':attribute长度不能超过:rule位',
		'roleId.require'	=> '请输入:attribute',
		'roleId.integer' => ':attribute应该是整数',
		'roleId.egt'	=> ':attribute应该大于等于:rule',
		'roleId.max'	=> ':attribute长度不能超过:rule位',
		'status.require'	=> '请输入:attribute',
		'status.integer' => ':attribute应该是整数',
		'status.egt'	=> ':attribute应该大于等于:rule',
		'status.max'	=> ':attribute长度不能超过:rule位',
		'secretKey.require'	=> '请输入:attribute',
		'secretKey.scalar' => ':attribute应该是字符串',
		'secretKey.max'	=> ':attribute长度不能超过:rule位',
		'created.require'	=> '请输入:attribute',
		'created.integer' => ':attribute应该是整数',
		'created.egt'	=> ':attribute应该大于等于:rule',
		'created.max'	=> ':attribute长度不能超过:rule位',
		'updated.require'	=> '请输入:attribute',
		'updated.integer' => ':attribute应该是整数',
		'updated.egt'	=> ':attribute应该大于等于:rule',
		'updated.max'	=> ':attribute长度不能超过:rule位',
		'systemId.require'	=> '请输入:attribute',
		'systemId.integer' => ':attribute应该是整数',
		'systemId.egt'	=> ':attribute应该大于等于:rule',
		'systemId.max'	=> ':attribute长度不能超过:rule位',
		'departmentId.require'	=> '请输入:attribute',
		'departmentId.integer' => ':attribute应该是整数',
		'departmentId.egt'	=> ':attribute应该大于等于:rule',
		'departmentId.max'	=> ':attribute长度不能超过:rule位',
        'page.require'      => '请输入:attribute',
        'page.integer'      => ':attribute应该是整数',
        'page.egt'          => ':attribute应该大于等于:rule',
        'page.max'          => ':attribute长度不能超过:rule位',
        'page_size.require' => '请输入:attribute',
        'page_size.integer' => ':attribute应该是整数',
        'page_size.egt'     => ':attribute应该大于等于:rule',
        'page_size.max'     => ':attribute长度不能超过:rule位',
    ];

    protected $scene = [
        'delete' => ['id' => 'require'],
        'index'  => ['page', 'page_size'],
        'read'   => ['id' => 'require'],
        'save'   => ['username', 'password', 'salt', 'isAdmin', 'name', 'mobile', 'email', 'roleId', 'status', 'secretKey', 'created', 'updated', 'systemId', 'departmentId'],
    ];

}
